package com.sz.sensor.adapter;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.blankj.utilcode.util.ActivityUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sz.framework.utils.ToastUtil;
import com.sz.sensor.R;
import com.sz.sensor.entity.MeEntity;
import com.sz.sensor.entity.SimpleEntity;
import com.sz.sensor.module.platform.MsgActivity;

public class PlatformAdapter extends BaseQuickAdapter<MeEntity, BaseViewHolder> {
    public PlatformAdapter() {
        super(R.layout.item_manage);
    }

    @Override
    protected void convert(BaseViewHolder helper, MeEntity item) {
        helper.setText(R.id.tv_title, item.getTitle());
        RecyclerView rvContent = helper.getView(R.id.rv_detail);
        ManageAdapter manageAdapter = new ManageAdapter();
        rvContent.setLayoutManager(new GridLayoutManager(mContext, 4));
        rvContent.setAdapter(manageAdapter);
        manageAdapter.setNewData(item.getEntities());
        manageAdapter.setOnItemClickListener((adapter, view, position) -> {
            SimpleEntity entity = (SimpleEntity) adapter.getItem(position);
            if (entity != null) {
                ToastUtil.showToast(entity.getTitle());
                if("发货".equals(entity.getTitle())){
                    ActivityUtils.startActivity(MsgActivity.class);
                }
            }
        });
    }
}
